﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using RED_NET_Core.Helper;
namespace RED_NET_Core.Entity
{
   public class Letter
    {
        #region [Private member]
        private int _id;
        private int _uIdOfSend;
        private int _uIdOfRecv;
        private int _isRead;
        private int _letterId;

        #endregion
        #region [Properties Of Album]

        public int Id
        {
            get { return _id; }
            set { _id = value; }
        }
        public int UIdOfSend
        {
            get { return _uIdOfSend; }
            set { _uIdOfSend = value; }
        }
        public int UIdOfRecv
        {
            get { return _uIdOfRecv; }
            set { _uIdOfRecv = value; }
        }
        public int IsRead
        {
            get { return _isRead; }
            set { _isRead = value; }
        }
        public int LetterId
        {
            get { return _letterId; }
            set { _letterId = value; }
        }
        #endregion
        public int AddItem()
        {
            int _id = -1;
            SqlParameter[] _param = new SqlParameter[4];
            _param[0] = new SqlParameter("@UIdOfSend", _uIdOfSend.ToString());
            _param[1] = new SqlParameter("@UIdOfRecv", _uIdOfRecv.ToString());
            _param[2] = new SqlParameter("@IsRead", _isRead.ToString());
            _param[3] = new SqlParameter("@LetterId", _letterId.ToString());
            string _smdStr = "insert into _Letter(_UIdOfSend,_UIdOfRecv,_IsRead,_LetterId) values(@UIdOfSend,@UIdOfRecv,@IsRead,@LetterId) SELECT   SCOPE_IDENTITY()   as   '_Id'";
            OwnSqlHelper _shp = new OwnSqlHelper();
            try
            {
                _id = Int32.Parse(_shp.ExecuteScalar(_smdStr, _param));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return _id;

        }
    }
}
